Imports DTO
Imports System.Data.OleDb

Public Class QuyDinhDAO

    Public Shared Sub CapNhat(ByVal qd As QuyDinhDto)
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        If cn.State = ConnectionState.Open Then
            Dim sqlstr = "Update from ThamSo Set SoTietToiDaTrongNgay = " + qd.SoTietToiDa.ToString() + _
            +", TietGay = " + qd.TietGay.ToString() + ", SoTietToiDaDuocHocTrongNgay = " + qd.ToiDaDuocHoc.ToString()
            Dim cmd As New OleDbCommand(sqlstr, cn)
            cmd.ExecuteNonQuery()
            cn.Close()
        End If
    End Sub

    Public Shared Function LayQuyDinh() As QuyDinhDto
        Dim qd As New QuyDinhDto
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        If cn.State = ConnectionState.Open Then
            Dim cmd As New OleDbCommand("Select * From ThamSo", cn)
            Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
            reader.Read()
            qd.SoTietToiDa = reader("SoTietToiDaTrongNgay")
            qd.TietGay = reader("TietGay")
            qd.ToiDaDuocHoc = reader("SoTietToiDaDuocHocTrongNgay")
            reader.Close()
            cn.Close()
        End If
        Return qd
    End Function
End Class
